package com.ccs.hanke.design;

import com.ccs.hanke.entity.Furit;

import java.util.HashMap;
import java.util.Map;

public class CalDiscountfull100Strategy implements Cal {
    @Override
    public double calSum(HashMap<String, Integer> map) {
        if(map.size()==0||map.isEmpty()){
            return -1;
        }

        double sumcount = 0;
        for(Map.Entry<String, Integer> entry:map.entrySet()){
            if(entry.getKey().equals("apple".toLowerCase())){
                sumcount += entry.getValue()*8;
            }
            if(entry.getKey().equals("strawberry".toLowerCase())){
                sumcount += entry.getValue()*13;
            }
            if(entry.getKey().equals("mango".toLowerCase())){
                sumcount += entry.getValue()*20;
            }
        }

        if(sumcount>100){
            return sumcount-10;
        }

        return sumcount;
    }

    @Override
    public double calFuritSum(HashMap<Furit, Integer> map) {
        if(map.size()==0||map.isEmpty()){
            return -1;
        }


        double sumcount = 0;
        for(Map.Entry<Furit, Integer> entry:map.entrySet()){
            sumcount+=entry.getKey().getPrice()*entry.getValue();
        }


        if(sumcount>100){
            return sumcount-10;
        }

        return sumcount;
    }
}
